home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / convertdb / convertdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  2.6 KB  |  107 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <clib/exec_protos.h>
  6. struct User {
  7.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  8.  USHORT  Slot_Number;
  9.  USHORT  Sec_Status,
  10.      Sec_Board,                   /* File or Byte Ratio */
  11.      Sec_Library,                 /* Ratio              */
  12.      Sec_Bulletin,                /* Computer Type      */
  13.      Messages_Posted;
  14.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  15.  ULONG   NewSinceDate, ConfRead[9];
  16.  char    Conference_Access[10];
  17.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  18.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  19.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  20.  char    Expert;
  21.  ULONG   ConfYM[9];
  22.  long    BeginLogCall;
  23.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  24.  };
  25. char BBSLocal[200];
  26. char UserData[200];
  27. char AreaList[200];
  28. char AreaBuffer[200];
  29. void GetArea(char *s,char *f);
  30. void sr(char *s);
  31. main(int argc,char *argv[])
  32. {
  33.    FILE *fi,*fo,*fo2;
  34.    struct User u;
  35.    int Areas=FALSE;
  36.    int i;
  37.    if(argc<2)
  38.    {
  39.      printf("ConvertDB version 1.1 written by Joseph Hodge\n");
  40.      printf("Usage: ConvertDB <UserData location> <AreaList>\n");
  41.      printf("   ie: ConvertDB BBS:User.Data\n");
  42.      printf("   ie: ConvertDB BBS:User.Data bbs:AreaList\n");
  43.  
  44.      printf("\n");
  45.      exit(0);
  46.    }
  47.    if(argc==3) { strcpy(AreaList,argv[2]); sr(AreaList); Areas=TRUE; }
  48.    
  49.    strcpy(BBSLocal,argv[1]);
  50.    sr(BBSLocal);
  51.    if(!Areas) { strcpy(AreaList,BBSLocal); strcat(AreaList,".Lst"); }
  52.    strcpy(UserData,BBSLocal);
  53.    strcat(UserData,".new");
  54.    fi=fopen(BBSLocal,"rb");
  55.    
  56.    if(fi==NULL)
  57.    {
  58.      printf("Error, can't locate user.data\n");
  59.      exit(0);
  60.    }
  61.    fo=fopen(UserData,"wb");
  62.    if(!Areas) fo2=fopen(AreaList,"w");
  63.    while(fread((APTR)&u,sizeof(struct User),1,fi)!=NULL)
  64.    {
  65.      if(!Areas) fprintf(fo2,"%-9.9s= \n",u.Conference_Access);
  66.      else
  67.      {
  68.         GetArea(u.Conference_Access,AreaList);
  69.         strcpy(u.Conference_Access,AreaBuffer);
  70.         fwrite((APTR)&u,sizeof(struct User),1,fo);
  71.      }
  72.    }
  73.    if(!Areas) fclose(fo2);
  74.    fclose(fo);
  75.    fclose(fi);
  76.  
  77. }
  78. void GetArea(char *s,char *f)
  79. {
  80.   FILE *fi;
  81.   char temp[100];
  82.   fi=fopen(f,"r");
  83.   if(fi==NULL) strcpy(AreaBuffer,"Standard");
  84.   while(fgets(temp,80,fi)!=NULL)
  85.   {
  86.      sr(temp);
  87.      if(!strnicmp(temp,s,9))
  88.      {
  89.        strcpy(AreaBuffer,&temp[11]);
  90.        fclose(fi);
  91.        return;
  92.      }
  93.   }
  94.   fclose(fi);
  95.   strcpy(AreaBuffer,"Standard");
  96. }
  97. void sr(char *s)
  98. {
  99.    register int i;
  100.    i=strlen(s)-1;
  101.    while(i>-1)
  102.    {
  103.      if(*(s+i)<=32) *(s+i)='\0'; else break;
  104.      i--;
  105.    }
  106. }
  107.